package com.byxy.luntan.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.byxy.luntan.entity.Reply;

public interface ReplyDao {
	
	
//	 `reply_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '回复id',
//	  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '回复人id',
//	  `tip_id` int(11) NOT NULL DEFAULT '0' COMMENT '被回复贴id',
//	  `reply_content` text COLLATE utf8_bin NOT NULL COMMENT '回复内容',
//	  `reply_publishTime` datetime DEFAULT NULL COMMENT '回复发表时间',
//	  `reply_modifyTime` datetime DEFAULT NULL COMMENT '回复修改时间',
//	  `reply_status` int(11) NOT NULL DEFAULT '0' COMMENT '回复状态，0正常，1逻辑删除',
	
	@Results(id="rep",value={
			@Result(column="reply_id",property="replyId",id=true),
			@Result(column="user_id",property="userId"),
			@Result(column="tip_id",property="tipId"),
			@Result(column="reply_content",property="replyContent"),
			@Result(column="reply_publishTime",property="replyPublishTime"),
			@Result(column="reply_modifyTime",property="replyModifyTime"),
			@Result(column="reply_status",property="replyStatus")
			
		})
	@Select("select * from reply where tip_id = #{tipId}")
	List<Reply> findByTipId(Integer tipId);
	
	@Insert("insert into reply(tip_id,reply_content,user_id) values(#{tipId},#{replyContent},#{userId})")
	public void add(@Param("tipId")Integer tipId, @Param("replyContent")String replyContent, @Param("userId")Integer userId);
	
	@Delete("delete from tip where tab_id=#{tipId}")
	public void delete(@Param("tipId")Integer tipId);
	
	
}
